// ValidationAspects
// Written by Mike Saunders
// Released under Microsoft Public License (Ms-PL)
using NUnit.Framework;
using ValidationAspects;
using ValidationAspects.Exceptions;
using ValidationAspects.Sdk;

namespace TestValidationAspects.Sdk
{
	[TestFixture]
	public class TestValidatorFactoryBase
	{
		[Test]
		public void Test_Create_creates_a_validator_which_executes_the_provided_validate_action()
		{
			MockValidatorFactory<double> factory = new MockValidatorFactory<double>();
			IValidationContext context = new MockValidationContext();

			IValidator<double> validator = factory.Create<double>();
			validator.Invoke(1, context);

			Assert.AreEqual(1, factory.Value);
			Assert.AreSame(context, factory.Context);
		}

		[Test]
		[ExpectedException(typeof(UnsupportedValidationException))]
		public void Test_Create_throws_for_unsupported_type()
		{
			new MockValidatorFactory<double>().Create<int>();
		}
	}
}